<template>
	<view class="list">
		<view class="flex_col" :class="{'active':pickerUserIndex==index}" :key="index" :data-index="index">
			<view class="flex_grow">
				<view class="flex_col">
					<view class="flex_grow">课程编号</view>
					<view>
						{{cursePlan.cursePlanNo}}
					</view>
				</view>
			</view>
		</view>
		<view class="flex_col" :class="{'active':pickerUserIndex==index}" :key="index" :data-index="index">
			<view class="flex_grow">
				<view class="flex_col">
					<view class="flex_grow">课程名</view>
					<view>
						{{cursePlan.curseTitle}}
					</view>
				</view>
			</view>
		</view>
		<view class="flex_col" :class="{'active':pickerUserIndex==index}" :key="index" :data-index="index">
			<view class="flex_grow">
				<view class="flex_col">
					<view class="flex_grow">开始时间</view>
					<view>
						{{cursePlan.curseStartTime}}
					</view>
				</view>
			</view>
		</view>
		<view class="flex_col" :class="{'active':pickerUserIndex==index}" :key="index" :data-index="index">
			<view class="flex_grow">
				<view class="flex_col">
					<view class="flex_grow">课程时长</view>
					<view>
						{{cursePlan.cursePeriod}}分钟
					</view>
				</view>
			</view>
		</view>
		<view class="flex_col" :class="{'active':pickerUserIndex==index}" :key="index" :data-index="index">
			<view class="flex_grow">
				<view class="flex_col">
					<view class="flex_grow">课程状态</view>
					<view>
						<text v-if="cursePlan.curseStatus==2">已结课</text>
						<text v-if="cursePlan.curseStatus==1">课程进行中</text>
						<text v-if="cursePlan.curseStatus==0">等待上课</text>
					</view>
				</view>
			</view>
		</view>

		<view class="flex_col" :class="{'active':pickerUserIndex==index}" :key="index" :data-index="index">
			<view class="flex_grow">
				<view class="flex_col">
					<view class="flex_grow">卡路里消耗量</view>
					<view>
						{{cursePlan.curseKaluli}}
					</view>
				</view>
			</view>
		</view>
		<view>课程内容</view>
		<view>{{cursePlan.cursePlanContent}}</view>
	</view>
</template>

<script>
	import base from '@/common/base.js'
	export default {
		data() {
			return {
				cursePlan: []
			}
		},
		onLoad(options) {
			this.getCursePlanByCursePlanId(options.cursePlanId);
		},
		methods: {
			getCursePlanByCursePlanId(cursePlanId) {
				uni.request({
					url: base.urlPrefix + "yoga_app/curse-plan/coachGetCursePlanByCursePlanId",
					data: {
						cursePlanId: cursePlanId
					},
					success: (res) => {
						this.cursePlan = res.data.object;
					}
				});
			}
		}
	}
</script>

<style scoped lang="scss">
	/* 列式弹性盒子 */
	.flex_col {
		display: flex;
		flex-direction: row;
		flex-wrap: nowrap;
		justify-content: flex-start;
		align-items: center;
		align-content: center;
	}

	/* 弹性盒子弹性容器 */
	.flex_col .flex_grow {
		width: 0;
		-webkit-box-flex: 1;
		-ms-flex-positive: 1;
		flex-grow: 1;
	}

	.flex_row .flex_grow {
		-webkit-box-flex: 1;
		-ms-flex-positive: 1;
		flex-grow: 1;
	}

	/* 弹性盒子允许换行 */
	.flex_col.flex_wrap {
		-ms-flex-wrap: wrap;
		flex-wrap: wrap;
	}

	/* 列表 */
	.list {
		background-color: #fff;
		font-size: 28upx;
		color: #333;
		user-select: none;
		touch-callout: none;

		&>view {
			padding: 24upx 30upx;
			position: relative;

			&:active,
			&.active {
				background-color: #f3f3f3;
			}

			image {
				height: 80upx;
				width: 80upx;
				border-radius: 4px;
				margin-right: 20upx;
			}

			&>view {
				line-height: 40upx;

				.time,
				.info {
					color: #999;
					font-size: 24upx;
				}

				.time {
					width: 150upx;
					text-align: right;
				}

				.info {
					overflow: hidden;
					text-overflow: ellipsis;
					white-space: nowrap;
				}
			}
		}

		&>view:not(:first-child) {
			margin-top: 1px;

			&::after {
				content: '';
				display: block;
				height: 0;
				border-top: #CCC solid 1px;
				width: 620upx;
				position: absolute;
				top: -1px;
				right: 0;
				transform: scaleY(0.5);
				/* 1px像素 */
			}
		}
	}

	/* 遮罩 */
	.shade {
		position: fixed;
		z-index: 100;
		top: 0;
		right: 0;
		bottom: 0;
		left: 0;
		-webkit-touch-callout: none;

		.pop {
			position: fixed;
			z-index: 101;
			width: 200upx;
			box-sizing: border-box;
			font-size: 28upx;
			text-align: left;
			color: #333;
			background-color: #fff;
			box-shadow: 0 0 5px rgba(0, 0, 0, 0.5);
			line-height: 80upx;
			transition: transform 0.15s ease-in-out 0s;
			user-select: none;
			-webkit-touch-callout: none;
			transform: scale(0, 0);

			&.show {
				transform: scale(1, 1);
			}

			&>view {
				padding: 0 20upx;
				overflow: hidden;
				text-overflow: ellipsis;
				white-space: nowrap;
				user-select: none;
				-webkit-touch-callout: none;

				&:active {
					background-color: #f3f3f3;
				}
			}
		}
	}
</style>
